ajax('/admin/article/query', function (data) {
    document.querySelector('.table tbody').innerHTML = template('template', data.data)
})

function data() {
    ajax('/admin/article/query', function (data) {
        console.log(data)
        document.querySelector('.table tbody').innerHTML = template('template', data.data)
        console.log(document.querySelectorAll('.text-center .btn-default'))
        document.querySelectorAll('.text-center .btn-default').forEach(function (item) {
            item.onclick = function () {
                console.log(this.dataset.id)
                //location.href = `article_list.html?id=${encodeURI(this.dataset.id)}`
            }
        })

        function initPager() {
            layui.use('laypage', function () {
                let laypage = layui.laypage;
                laypage.render({
                    elem: 'pager',
                    count: data.data.totalCount,
                    limit: 6,
                    curr: 1,
                    jump: function (obj, first) {
                        if (!first) {
                            ajax('/admin/article/query', function (data) {
                                document.querySelector('.table tbody').innerHTML = template('template', data.data)
                            }, 'get', `page=${obj.curr}`)
                        }
                    }
                });
            })
        }
        initPager()
    })
}
data()